#!/usr/bin/python
#coding:utf-8
"""在ubuntu下听豆瓣歌曲"""

import httplib

import json

import os

import sys

import subprocess

import time

reload(sys)

sys.setdefaultencoding('utf-8')

while True:

# 获取播放列表      
	httpConnection = httplib.HTTPConnection('douban.fm')
	httpConnection.request('GET', '/j/mine/playlist?type=n&channel=0')
	song = json.loads(httpConnection.getresponse().read())['song']
# 播放      
	player = subprocess.Popen(['mplayer', song[0]['url']])
	time.sleep(song[0]['length'])
